package com.lzw.mapper.student;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Map;

@Mapper
public interface StudentMapper {
    @Select("SELECT student_id FROM dormitorymanagement.student WHERE username = #{username} AND password = #{password}")
    Integer checkCredentials(@Param("username") String username, @Param("password") String password);

    @Select("SELECT student_id, name, username, gender, phone, email, image, dormitory_Id, building_id FROM dormitorymanagement.student WHERE username = #{username} AND password = #{password}")
    Map<String, Object> getStudentInfo(@Param("username") String username, @Param("password") String password);

    @Select("SELECT student_id, name, username, gender, phone, email, image, dormitory_Id, building_id FROM dormitorymanagement.student WHERE student_id = #{studentId}")
    Map<String, Object> getStudentInfoById(@Param("studentId") Integer studentId);

    @Update("UPDATE dormitorymanagement.student SET name = #{name}, gender = #{gender}, phone = #{phone}, email = #{email} WHERE student_id = #{studentId}")
    int updateAdminInfo(@Param("studentId") Integer studentId, @Param("name") String name,
                        @Param("gender") String gender, @Param("phone") String phone,
                        @Param("email") String email);
}
